/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ace.game;

import ace.geometry.Vertex2D;
import ace.system.GameRandom;
import ace.system.StateManager;
import ace.system.Utilities;

/**
 *
 * @author Hallucinogen
 */
public class Path {
	public Path(String pathString) {
		String[] paths = Utilities.split(pathString, ";");
        for (int i = 0; i < paths.length; ++i) {
            paths[i] = paths[i].trim();
        }

        mPositions  = new Vertex2D[paths.length];
        mTiming  = new int[paths.length];

        for (int i = 0; i < paths.length; ++i) {
            String[] parts = Utilities.split(paths[i], ",");
            int x = GameRandom.intRandom(StateManager.instance().getRow() * Utilities.TILE_WIDTH);
            int y = 0;
            int time = 0;
            if (!parts[0].equals("r")) {
                x = Integer.parseInt(parts[0]);
            }
            if (!parts[1].equals("r")) {
                y = Integer.parseInt(parts[1]);
            }
            if (!parts[2].equals("r")) {
                time = Integer.parseInt(parts[2]);
            }
            mPositions[i] = new Vertex2D(x, y);
            mTiming[i] = time;
        }
	}

	public Path(Vertex2D[] positions, int[] timing) {
		mPositions		= positions;
        mTiming         = timing;
	}

	public Vertex2D getPositions(int index) {   return mPositions[index];   }
	public int getTiming(int index)         {	return mTiming[index];      }
    public int getPathingCount()            {   return mPositions.length;   }

	private Vertex2D[] mPositions;
    private int[] mTiming;
}
